#include <iostream>
using namespace std;

int sum(int n)
{
	int count = 0;
	while(n > 0)
	{
		if(n % 10 == 2)	count++;
		n /= 10;
	}
	return count;
}
int main() {
	int l = 0;
	int r = 0;
	int cnt = 0;
	cin >> l >> r;
	for(int i = l; i <= r; i++)
	{
		cnt += sum(i);
	}
	cout << cnt << endl;
    return 0;
}

